package com.gree.flowable.app.tools.pattern;

import com.gree.flowable.app.pojo.ex.FlowElementEx;
import com.gree.flowable.app.pojo.vo.NextChooseVO;
import com.gree.flowable.app.tools.constants.NextNodeType;

import java.util.List;


/**
 * 策略模式
 * @param <T>
 */
public class NextVoContext<T> {
    private String type;
    private AllotNodeVoStrategy as;
    public NextVoContext(String type){
        this.type = type;
        switch (type){
            case NextNodeType.CHOOSE:
                ChooseStrategy chooseAllotStrategy = new ChooseStrategy();
                as = chooseAllotStrategy;
                break;
            case NextNodeType.COUNTERSIGN:
                AllAllotStrategy allAllotStrategy = new AllAllotStrategy();
                as = allAllotStrategy;
                break;
            case NextNodeType.END:
                OneAllotStrategy nullAllotStrategy = new OneAllotStrategy();
                as = nullAllotStrategy;
                break;
            case NextNodeType.ONE:
                OneAllotStrategy oneAllotStrategy = new OneAllotStrategy();
                as = oneAllotStrategy;
                break;
            case NextNodeType.JUMP:
                OneAllotStrategy directStrategy = new OneAllotStrategy();
                as = directStrategy;
                break;
            default:

        }
    }

    public NextChooseVO getResult(T data1, List<FlowElementEx> data2){
        List pass = as.pack(data1);
        ChooseStrategy strategy = new ChooseStrategy();
        List reject = strategy.pack(data2);
        return new NextChooseVO(type, pass, reject);
    }
}
